/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.            */
/*                                                                 */
/*  NAME      = t__sqlserver_skip_partname.c                       */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/10 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <CUnit/Basic.h>

#include <frcomm.h>
#include <sqlserver/config.h>
#include <sqlserver/sqlserver_core.h>

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern int __sqlserver_skip_partname(Frbyte_Packet *p_st_data, int i_whole_flg);

static void __case1(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;

    p_st_data = bytebuff_creat();

    i_ret = __sqlserver_skip_partname(p_st_data, i_whole_flg);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);

    bytebuff_free(&p_st_data);
    return;
}

static void __case2(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x01\x01\x00\x65\x00\x08", 6);

    i_ret = __sqlserver_skip_partname(p_st_data, i_whole_flg);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);

    bytebuff_free(&p_st_data);
    return;
}

int add_suite__sqlserver_skip_partname(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __sqlserver_skip_partname()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    //增加测试用例
    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
